package com.yuzhihao.writejvm.format;

import com.yuzhihao.writejvm.code.a.*;
import com.yuzhihao.writejvm.code.b.*;
import com.yuzhihao.writejvm.code.c.*;
import com.yuzhihao.writejvm.code.d.*;
import com.yuzhihao.writejvm.code.f.*;
import com.yuzhihao.writejvm.code.g.*;
import com.yuzhihao.writejvm.code.i.*;
import com.yuzhihao.writejvm.code.j.*;
import com.yuzhihao.writejvm.code.l.*;
import com.yuzhihao.writejvm.code.m.*;
import com.yuzhihao.writejvm.code.n.*;
import com.yuzhihao.writejvm.code.p.*;
import com.yuzhihao.writejvm.code.r.*;
import com.yuzhihao.writejvm.code.s.*;
import com.yuzhihao.writejvm.code.t.Tableswitch;
import com.yuzhihao.writejvm.code.w.Wide;

import java.util.HashMap;
import java.util.Map;

/**
 * 指令枚举(存在关键字则后面加 _)
 *
 * @author yzh
 * @see <a href ="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.1">jvmdoc</a>
 * @since 2021年12月16日15:35:11
 */
public enum FormsEnum {
    //
    aaload(50,"0x32", Aaload.class),
    aastore(83,"0x53", Aastore.class),
    aconst_null(1,"0x1",AconstNull.class),
    aload(25,"0x19", Aload.class),
    aload_0(42,"0x2a",Aload0.class),
    aload_1(43,"0x2b", Aload1.class),
    aload_2(44,"0x2c", Aload2.class),
    aload_3(45,"0x2d",Aload3.class),
    anewarray(189,"0xbd",Anewarray.class),
    areturn(176,"0xb0",Areturn.class),
    arraylength(190,"0xbe",Arraylength.class),
    astore(58,"0x3a",Astore.class),
    astore_0(75,"0x4b",Astore0.class),
    astore_1(76,"0x4c",Astore1.class),
    astore_2(77,"0x4d",Astore2.class),
    astore_3(78,"0x4e",Astore3.class),
    athrow(191,"0xbf",Athrow.class),
    baload(51,"0x33",Baload.class),
    bastore(84,"0x54",Bastore.class),
    bipush(16,"0x10",Bipush.class),
    caload(52,"0x34",Caload.class),
    castore(85,"0x55",Castore.class),
    checkcast(192,"0xc0",Checkcast.class),
    d2f(144,"0x90",D2f.class),
    d2i(142,"0x8e",D2i.class),
    d2l(143,"0x8f",D2l.class),
    dadd(99,"0x63",Dadd.class),
    daload(49,"0x31",Daload.class),
    dastore(82,"0x52",Dastore.class),
    dcmpg(152,"0x98",Dcmpg.class),
    dcmpl(151,"0x97",Dcmpl.class),
    dconst_0(14,"0xe",Dconst0.class),
    dconst_1(15,"0xf",Dconst1.class),
    ddiv(111,"0x6f",Ddiv.class),
    dload(24,"0x18",Dload.class),
    dload_0(38,"0x26",Dload0.class),
    dload_1(39,"0x27",Dload1.class),
    dload_2(40,"0x28",Dload2.class),
    dload_3(41,"0x29",Dload3.class),
    dmul(107,"0x6b",Dmul.class),
    dneg(119,"0x77",Dneg.class),
    drem(115,"0x73",Drem.class),
    dreturn(175,"0xaf",Dreturn.class),
    dstore(57,"0x39",Dstore.class),
    dstore_0(71,"0x47",Dstore0.class),
    dstore_1(72,"0x48",Dstore1.class),
    dstore_2(73,"0x49",Dstore2.class),
    dstore_3(74,"0x4a",Dstore3.class),
    dsub(103,"0x67",Dsub.class),
    dup(89,"0x59",Dup.class),
    dup_x1(90,"0x5a",DupX1.class),
    dup_x2(91,"0x5b",DupX2.class),
    dup2(92,"0x5c",Dup2.class),
    dup2_x1(93,"0x5d",Dup2X1.class),
    dup2_x2(94,"0x5e",Dup2X2.class),
    f2d(141,"0x8d",F2d.class),
    f2i(139,"0x8b",F2i.class),
    f2l(140,"0x8c",F2l.class),
    fadd(98,"0x62",Fadd.class),
    faload(48,"0x30",Faload.class),
    fastore(81,"0x51",Fastore.class),
    fcmpg(150,"0x96",Fcmpg.class),
    fcmpl(149,"0x95",Fcmpg.class),
    fconst_0(11,"0xb",Fconst0.class),
    fconst_1(12,"0xc",Fconst1.class),
    fconst_2(13,"0xd",Fconst2.class),
    fdiv(110,"0x6e",Fdiv.class),
    fload(23,"0x17",Fload.class),
    fload_0(34,"0x22",Fload0.class),
    fload_1(35,"0x23",Fload1.class),
    fload_2(36,"0x24",Fload2.class),
    fload_3(37,"0x25",Fload3.class),
    fmul(106,"0x6a",Fmul.class),
    fneg(118,"0x76",Fneg.class),
    frem(114,"0x72",Frem.class),
    freturn(174,"0xae",Freturn.class),
    fstore(56,"0x38",Fstore.class),
    fstore_0(67,"0x43",Fstore0.class),
    fstore_1(68,"0x44",Fstore1.class),
    fstore_2(69,"0x45",Fstore2.class),
    fstore_3(70,"0x46",Fstore3.class),
    fsub(102,"0x66",Fsub.class),
    getfield(180,"0xb4",Getfield.class),
    getstatic(178,"0xb2", Getstatic.class),
    goto_(167,"0xc8",Goto.class),
    goto_w(200,"0x32",GotoW.class),
    i2b(145,"0x91",I2b.class),
    i2c(146,"0x92",I2c.class),
    i2d(135,"0x87",I2d.class),
    i2f(134,"0x86",I2f.class),
    i2l(133,"0x85",I2l.class),
    i2s(147,"0x93",I2s.class),
    iadd(96,"0x60",Iadd.class),
    iaload(46,"0x2e",Iaload.class),
    iand(126,"0x7e",Iand.class),
    iastore(79,"0x4f",Iastore.class),
    iconst_m1(2,"0x2",IconstM1.class),
    iconst_0(3,"0x3",Iconst0.class),
    iconst_1(4,"0x4",Iconst1.class),
    iconst_2(5,"0x5",Iconst2.class),
    iconst_3(6,"0x6",Iconst3.class),
    iconst_4(7,"0x7",Iconst4.class),
    iconst_5(8,"0x8",Iconst5.class),
    idiv(108,"0x6c",Idiv.class),
    if_acmpeq(165,"0xa5",IfAcmpeq.class),
    if_acmpne(166,"0xa6",IfAcmpne.class),
    if_icmpeq(159,"0x9f",IfIcmpeq.class),
    if_icmpne(160,"0xa0",IfIcmpne.class),
    if_icmplt(161,"0xa1",IfIcmplt.class),
    if_icmpge(162,"0xa2",IfIcmpge.class),
    if_icmpgt(163,"0xa3",IfIcmpgt.class),
    if_icmple(164,"0xa4",IfIcmple.class),
    ifeq(153,"0x99",Ifeq.class),
    ifne(154,"0x9a",Ifne.class),
    iflt(155,"0x9b",Iflt.class),
    ifge(156,"0x9c",Ifge.class),
    ifgt(157,"0x9d",Ifgt.class),
    ifle(158,"0x9e",Ifle.class),
    ifnonnull(199,"0xc7",Ifnonnull.class),
    ifnull(198,"0xc6",Ifnull.class),
    iinc(132,"0x84",Iinc.class),
    iload(21,"0x15",Iload.class),
    iload_0(26,"0x1a",Iload0.class),
    iload_1(27,"0x1b",Iload1.class),
    iload_2(28,"0x1c",Iload2.class),
    iload_3(29,"0x1d",Iload3.class),
    imul(104,"0x68",Imul.class),
    ineg(116,"0x74",Ineg.class),
    instanceof_(193,"0xc1",Instanceof.class),
    invokedynamic(186,"0xba",Invokedynamic.class),
    invokeinterface(185,"0xb9",Invokeinterface.class),
    invokespecial(183,"0xb7",Invokespecial.class),
    invokestatic(184,"0xb8",Invokestatic.class),
    invokevirtual(182,"0xb6",Invokevirtual.class),
    ior(128,"0x80",Ior.class),
    irem(112,"0x70",Irem.class),
    ireturn(172,"0xac",Ireturn.class),
    ishl(120,"0x78",Ishl.class),
    ishr(122,"0x7a",Ishr.class),
    istore(54,"0x36",Istore.class),
    istore_0(59,"0x3b",Istore0.class),
    istore_1(60,"0x3c",Istore1.class),
    istore_2(61,"0x3d",Istore2.class),
    istore_3(62,"0x3e",Istore3.class),
    isub(100,"0x64",Isub.class),
    iushr(124,"0x7c",Iushr.class),
    ixor(130,"0x82",Ixor.class),
    jsr(168,"0xa8",Jsr.class),
    jsr_w(201,"0xc9",JsrW.class),
    l2d(138,"0x8a",L2d.class),
    l2f(137,"0x89",L2f.class),
    l2i(136,"0x88",L2i.class),
    ladd(97,"0x61",Ladd.class),
    laload(47,"0x2f",Laload.class),
    land(127,"0x7f",Land.class),
    lastore(80,"0x50",Lastore.class),
    lcmp(148,"0x94",Lcmp.class),
    lconst_0(9,"0x9",Lconst0.class),
    lconst_1(10,"0xa",Lconst1.class),
    ldc(18,"0x12",Ldc.class),
    ldc_w(19,"0x13",LdcW.class),
    ldc2_w(20,"0x14",Ldc2W.class),
    ldiv(109,"0x6d",Ldiv.class),
    lload(22,"0x16",Lload.class),
    lload_0(30,"0x1e",Lload0.class),
    lload_1(31,"0x1f",Lload1.class),
    lload_2(32,"0x20",Lload2.class),
    lload_3(33,"0x21",Lload3.class),
    lmul(105,"0x69",Lmul.class),
    lneg(117,"0x75",Lneg.class),
    lookupswitch(171,"0xab",Lookupswitch.class),
    lor(129,"0x81",Lor.class),
    lrem(113,"0x71",Lrem.class),
    lreturn(173,"0xad",Lreturn.class),
    lshl(121,"0x79",Lshl.class),
    lshr(123,"0x7b",Lshr.class),
    lstore(55,"0x37",Lstore.class),
    lstore_0(63,"0x3f",Lstore0.class),
    lstore_1(64,"0x40",Lstore1.class),
    lstore_2(65,"0x41",Lstore2.class),
    lstore_3(66,"0x42",Lstore3.class),
    lsub(101,"0x65",Lsub.class),
    lushr(125,"0x7d",Lushr.class),
    lxor(131,"0x83",Lxor.class),
    monitorenter(194,"0xc2", Monitorenter.class),
    monitorexit(195,"0xc3", Monitorexit.class),
    multianewarray(197,"0xc5", Multianewarray.class),
    new_(187,"0xbb", New.class),
    newarray(188,"0xbc", Newarray.class),
    nop(0,"0x0", Nop.class),
    pop(87,"0x57", Pop.class),
    pop2(88,"0x58", Pop2.class),
    putfield(181,"0xb5", Putfield.class),
    putstatic(179,"0xb3", Putstatic.class),
    ret(169,"0xa9", Ret.class),
    return_(177,"0xb1", Return.class),
    saload(53,"0x35", Saload.class),
    sastore(86,"0x56", Sastore.class),
    sipush(17,"0x11", Sipush.class),
    swap(95,"0x5f", Swap.class),
    tableswitch(170,"0xaa", Tableswitch.class),
    wide(196,"0xc4", Wide.class);

    private final int value;
    private final String valuex;
    private final Class<?> clazz;

    private final static Map<Integer,FormsEnum> VALUS = new HashMap<>();
    
    static {
        for (FormsEnum value : FormsEnum.values()) {
            VALUS.put(value.getValue(),value);
        }
    }
    
    FormsEnum(int value, String valuex,Class<?> clazz) {
        this.value = value;
        this.valuex = valuex;
        this.clazz = clazz;
    }

    public int getValue() {
        return value;
    }

    public String getValuex() {
        return valuex;
    }

    public Class<?> getClazz() {
        return clazz;
    }

    public static FormsEnum instance(int value){
        return VALUS.get(value);
    }
}
